package com.app.knock.db;

import java.util.ArrayList;
import java.util.List;

import z.lib.base.DataStore;
import z.lib.base.OnChangLanguage;
import android.content.Context;


public class Setting extends SkypeTable {
	public Setting(Context context) {
		super(context);

		addColumns(lang);
	}

	public static final String lang = "lang";

	@Override
	public int getIndex() {
		return 4;
	}

	/**
	 * 
	 * @param eng
	 *            R.id.eng R.id.ja
	 */
	public void saveLang(int eng) {
//		boolean isLangEng = isLangEng();
//		DataStore.getInstance().save("saveLang", eng == R.id.eng);
//		if (isLangEng != isLangEng()) {
//			for (OnChangLanguage changLanguage : lOnchangLaguage) {
//				changLanguage.sendEmptyMessage(0);
//			}
//		}

	}

	public boolean isLangEng() {
		DataStore.getInstance().init(getContext());
		return DataStore.getInstance().get("saveLang", true);
	}

	private static List<OnChangLanguage> lOnchangLaguage = new ArrayList<OnChangLanguage>();

	public static void registerOnChangLanguage(OnChangLanguage changLanguage) {
		lOnchangLaguage.add(changLanguage);
	}

	public void unRegisterOnChangLanguage(OnChangLanguage changLanguage) {
		lOnchangLaguage.remove(changLanguage);
	}

	public String getLangStr() {
		return isLangEng() ? "eng" : "ja";
	}
}